local skel = fk.CreateSkill({
    name = "lb__baie_ren",
    tags = {Skill.Limited},
})
  
Fk:loadTranslationTable{
  ["lb__baie_ren"] = "百锷",
  --[":lb__baie_ren"] = "<b>限定技</b>，出牌阶段，你可以将所有装备栏改为武器栏，然后从弃牌堆获得至多4张武器牌，本局游戏你使用的伤害牌响应牌数+X（X为你装备的武器数）。",
  --9.18
  [":lb__baie_ren"] = "<b>限定技</b>，出牌阶段，你可以将所有装备栏改为武器栏，然后从弃牌堆获得至多4张武器牌，本局游戏你使用的伤害牌响应牌数改为X（X为你装备的武器数且至少为1）。",

  ["#lb__baie_ren"] = "百锷：你可以将所有装备栏改为武器栏，然后从弃牌堆获得至多4张武器牌",
  ["#lb__baie_weapon"] = "百锷：你可以获得至多4张武器牌",
  ["@@lb__baie_ren"] = "百锷",

  ["$lb__baie_ren1"] = "此番美景，我虽求而不得。",
  ["$lb__baie_ren2"] = "见证我的痛苦，我的一招一式。",
}

skel:addEffect("active", {
  anim_type = "drawcard",
  prompt = "#lb__baie_ren",
  can_use = function (self, player)
    if player:usedSkillTimes(skel.name, Player.HistoryGame) > 0 then return false end
    local subtypes = {Card.SubtypeArmor, Card.SubtypeDefensiveRide, Card.SubtypeOffensiveRide, Card.SubtypeTreasure}
    for _, sub in ipairs(subtypes) do
      if #player:getAvailableEquipSlots(sub) > 0 then
        return true
      end
    end
  end,
  card_filter = Util.FalseFunc,
  target_filter = Util.FalseFunc,
  on_use = function (self, room, skillUseEvent)
    local player = skillUseEvent.from
    local subtypes = {Card.SubtypeArmor, Card.SubtypeDefensiveRide, Card.SubtypeOffensiveRide, Card.SubtypeTreasure}
    for _, sub in ipairs(subtypes) do
      local equipSlots = player:getAvailableEquipSlots(sub)
      if #equipSlots > 0 then
        room:abortPlayerArea(player, equipSlots)
        for _ = 1, #equipSlots, 1 do
          room:addPlayerEquipSlots(player, { Player.WeaponSlot })
        end
      end
    end
    room:setPlayerMark(player, "@@lb__baie_ren", 1)
    local ids = table.filter(room.discard_pile,function (id)
      return Fk:getCardById(id).sub_type == Card.SubtypeWeapon
    end)
    if #ids == 0 then return end
    local cards = room:askToCards(player,{
      min_num = 1,
      max_num = 4,
      skill_name = skel.name,
      expand_pile = ids,
      pattern = tostring(Exppattern{ id = ids }),
      cancelable = true,
      prompt = "#lb__baie_weapon",
    })
    if #cards > 0 then
      room:obtainCard(player, cards, true, fk.ReasonJustMove, player, skel.name)
    end
  end,
})

skel:addEffect(fk.TargetConfirmed, {
  can_refresh = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and data.from == player 
    and player:getMark("@@lb__baie_ren") > 0 and data.card.is_damage_card
    and #table.filter(player:getCardIds("e"), function (id)
      return Fk:getCardById(id).sub_type == Card.SubtypeWeapon
    end) > 0
  end,
  on_refresh = function(self, event, target, player, data)
    local num = #table.filter(player:getCardIds("e"), function (id)
      return Fk:getCardById(id).sub_type == Card.SubtypeWeapon
    end)
    --data:setResponseTimes(data:getResponseTimes(target) + num, target)
    data:setResponseTimes(math.max(num, 1), target)
  end,
})

skel:addLoseEffect(function (self, player, is_death)
  player.room:setPlayerMark(player, "@@lb__baie_ren", 0)
end)


return skel